﻿using UnityEngine;
using System.Collections;

public class stg3_cardScript : MonoBehaviour {
    //public Transform click_effect;  //11월 15일 particle 추가
    bool open = false;
    int currentCard = 0;
    //public Camera mainCamera;
    void Start()
    {
        gameObject.renderer.material.color = new Color(gameObject.renderer.material.color.r, gameObject.renderer.material.color.g, gameObject.renderer.material.color.b, 0.5f);
        gameObject.transform.Rotate(90, 0, 0);
    }
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnMouseUp()
    {
        if (open) return;
        animation.Play("aniOpen");						//클릭 시 애니메이션 실행
        currentCard = int.Parse(gameObject.tag.Substring(4));//오브젝트의 tag를 4번째 부터 끝까지 읽어온다.
        stg3_starter.currentCard = currentCard;					//starter에게 카드번호를 넘겨준다
        stg3_starter.state = stg3_starter.STATE.TOUCH;
        //Instantiate(click_effect, gameObject.transform.position, Quaternion.identity); //11월 15일 particle 추가
        
        
    }

    public void OpenImage()
    {
        currentCard = int.Parse(gameObject.tag.Substring(4));

        gameObject.renderer.material.mainTexture = (Texture)Resources.Load("Images/stg3/card" + currentCard);	
    }                               //해당 오브젝트의 표면을 해당 이미지로 바꾼다

    void CloseImage()
    {
        gameObject.renderer.material.mainTexture = (Texture)Resources.Load("Images/stg3/imgBack");
    }

    public void Open()
    {
        animation.Play("aniOpen");
        open = true;
    }

    public void Close()
    {
        animation.Play("aniClose");
        open = false;
    }
}
